<!DOCTYPE html>
<html>
  
  <head>
    <meta charset="UTF-8">
    <title>后台管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
     <link rel="stylesheet" href="../../css/font.css">
    <link rel="stylesheet" href="../../css/xadmin.css">
    <script type="text/javascript" src="../../js/jquery-3.2.1.js"></script>
    <script type="text/javascript" src="../../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../../js/xadmin.js"></script>
 
  </head>
  
  <body>
    <div class="x-body">
        <form class="layui-form" lay-filter="formTest">
          <div class="layui-form-item">
              <label for="fixBillId" class="layui-form-label">
                  ID
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="fixBillId" name="fixBillId" required="" lay-verify="number"
                  autocomplete="off" class="layui-input" disabled>
              </div>
              <label for="state" class="layui-form-label">
                    维修状态
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="state" name="state" required="required"
                  autocomplete="off" class="layui-input" disabled>
              </div>
          </div>
          <div class="layui-form-item">
              <label for="fixBillSendTime" class="layui-form-label">
                    申请时间    
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="fixBillSendTime" name="fixBillSendTime" required="date"
                  autocomplete="off" class="layui-input date-item" disabled>
              </div>
              <label for="checkBillTime" class="layui-form-label" >
                    接受时间    
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="checkBillTime" name="checkBillTime"  required="date"
                  autocomplete="off" class="layui-input date-item" disabled>
              </div>
          </div> 
          <div class="layui-form-item">
              <label for="userId" class="layui-form-label">
                  用户ID
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="userId" name="userId" required="" lay-verify="number"
                  autocomplete="off" class="layui-input" disabled >
              </div>
          
              <label for="presonName" class="layui-form-label">
                 用户
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="presonName" name="presonName" required="" lay-verify="number"
                  autocomplete="off" class="layui-input" disabled>
              </div>
          </div>
          <div class="layui-form-item">
              <label for="breakObject" class="layui-form-label">
                  物件
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="breakObject" name="breakObject" required="" lay-verify="required"
                  autocomplete="off" class="layui-input" disabled>
              </div>
          </div>
          <div class="layui-form-item">
              <label for="breakCause" class="layui-form-label">
                 问题描述
              </label>
              <div class="layui-input-block">
                  <textarea id="breakCause" name="breakCause"class="layui-textarea" lay-verify="required"  style="resize:none;width: 600px;height: 50px;" disabled></textarea>
              </div>
          </div>
          
          <div class="layui-form-item">
              <label for="workerName" class="layui-form-label">
                  	维修人员
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="workerName" name="workerName" required="required"
                  autocomplete="off" class="layui-input">
              </div>
              <label for="workerTelephone" class="layui-form-label">
                  	联系方式
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="workerTelephone" name="workerTelephone" required="phone"
                  autocomplete="off" class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label for="applyTime" class="layui-form-label">
                    预约时间    
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="applyTime" name="applyTime" required="date"
                  autocomplete="off" class="layui-input date-item">
              </div>
              <label for="finishTime" class="layui-form-label">
                    完成时间    
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="finishTime" name="finishTime" required="date"
                  autocomplete="off" class="layui-input date-item">
              </div>
          </div> 
          <div class="layui-form-item">
              <label for="processing" class="layui-form-label">
                  	过程描述
              </label>
              <div class="layui-input-block">
                 <textarea id="processing" name="processing" class="layui-textarea" lay-verify="required"  style="resize:none;width: 600px;height: 50px;" ></textarea>
              </div>
          </div>
          
          <div class="layui-form-item">
              <label for="L_repass" class="layui-form-label">
              </label>
              <button  class="layui-btn" lay-filter="add" lay-submit="">
                  更新
              </button>
              <button  class="layui-btn" lay-filter="reset" >
                  重置
              </button>
          </div>
      </form>
    </div>
    <script>
        layui.use(['form','laydate'], function(){
          var form = layui.form;
          var laydate = layui.laydate;
          var data = {enable:1};
	        if(window.location.href.indexOf("?")!=-1){
	        	 var para =  window.location.href.substr(window.location.href.indexOf("?")+1);
	        	 if(para != null && para != undefined && para.trim() != ''){
	                 para = para.replace(/=/g,':');
	                 para = para.replace(/&/g,',');
	                 data = $.extend({},data,eval('({'+para+'})'));
	                 console.log(data);
	                 console.log(para);
	             }
	        }
          if( data.fixBillId != null && data.fixBillId!= undefined ){
   					$.ajax({
   						type:"get",
   						url:"../findFix",
   						async: false,
   						data:data,
   						success:function(result){
   							result.state = fixState(result);
   							form.val("formTest", result);
   						},
   						error:function(){layer.alert("与服务器连接异常", {icon: 2});}
   					});
          }
          
          form.on('button(reset)', function() {
              form.val("formTest", result)
          });
          
          $('.date-item').each(function(){
        	    laydate.render({
        	      elem: this,
        	      type: 'datetime'
        	    });
          });
          
          form.on('submit(update)', function(data){
              
        	  $.ajax({
        		  url:'../updateFix',
        		  type:'post',
        		  async: true,
        		  data:data.field,
        		  success:function(result){
        			  if(result.msg == 'success'){
        				  layer.alert(result.msg, {icon: 1},function(){
        					  var index = parent.layer.getFrameIndex(window.name);
        					  parent.layer.close(index);
        					  parent.location.reload();
        				  });
                      }else{
                          layer.alert(result.msg, {icon: 2});
                      }
        		  },
        		  error:function(){layer.alert("与服务器连接异常", {icon: 2});}
        	  });
          });
        });
        
        function fixState(d){
            if(d.enable==2){
                return "已撤销";
            }
            if(d.isCheck){
                 var state="处理中";
                    if(d.isApply){
                        state="已安排师傅";
                        if(d.isFinish){
                            state="已完成";
                        }
                    }
                    return state;
            }else{
                return "待处理";
            }
        }
    </script>

  </body>

</html>